package com.entities.projectitem.servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.core.protocols.IServiceLayerDelegate;
import com.core.servlets.TaskTrackerServlet;
import com.core.utils.GlobalConstants;
import com.entities.projectitem.servicelayer.ProjectListLayer;

/**
 * Servlet implementation class ProjectDelete
 */

public class ProjectDelete
        extends TaskTrackerServlet
        implements IServiceLayerDelegate {

	private static final long serialVersionUID = 1L;



	@Override
	public <T> void responseResponseItemsList ( final List <T> items,
	                                            final Object request,
	                                            final Exception exception ) {

	}



	@Override
	protected void doPost ( HttpServletRequest request,
	                        HttpServletResponse response )
	        throws ServletException, IOException {

		String projectId = request.getParameter(GlobalConstants.SERVLET_PARAM_KEY);
		Integer objectId = null;
		try{
			objectId = Integer.parseInt(projectId);
		}catch(NumberFormatException e){
			objectId = null;
		}
		
		
		ProjectListLayer projectListLayer = new ProjectListLayer();
		projectListLayer.setLayerDelegate(this);
		projectListLayer.deleteObject(objectId);

	}



}
